package Game;

import java.util.List;
import java.util.ArrayList;
import java.util.Random;


public class game {
    private static final String[] SUITS = {"♥", "♠", "♣", "♦"};

    public List<poker> buypoker() {
        List<poker> pokers = new ArrayList<>();
        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 1; j <= 13; j++) {
                poker poker = new poker(SUITS[i], j);
                pokers.add(poker);
            }
        }
        return pokers;
    }

    public List<poker> suaffle(List<poker> pokers) {
        Random random = new Random();
        for (int i = pokers.size()-1; i > 0; i--) {
            int index = random.nextInt(i);
            poker tmp = pokers.get(i);
            pokers.set(i, pokers.get(index));
            pokers.set(index, tmp);
        }
        return pokers;
    }

    public void grant(List<poker> pokers) {
        List<poker> hand1 = new ArrayList<>();
        List<poker> hand2 = new ArrayList<>();
        List<poker> hand3 = new ArrayList<>();
        List<List<poker>> hand = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                hand.get(j).add(pokers.remove(0));
            }
        }
        System.out.println("第一个人的牌：");
        System.out.println(hand1);
        System.out.println("---------------------------");

        System.out.println("第二个人的牌：");
        System.out.println(hand2);
        System.out.println("---------------------------");

        System.out.println("第三个人的牌：");
        System.out.println(hand3);
        System.out.println("---------------------------");

        System.out.println("剩下的牌");
        System.out.println(pokers);

    }
}

